翻訳と辞書
Words near each other
・ Object pairing
・ Object Pascal
・ Object permanence
・ Object pool pattern
・ Object Process Graph
・ Object process methodology
・ Object pronoun
・ Object Query Language
・ Object relations theory
・ Object request broker
・ Object resurrection
・ Object Reuse and Exchange
・ Object REXX
・ Object sexuality
・ Object skill
Object slicing
・ Object storage
・ Object Technology International
・ Object theory
・ Object to Be Destroyed
・ Object type (object-oriented programming)
・ Object Value
・ Object Windows Library
・ Object-based attention
・ Object-based language
・ Object-based spatial database
・ Object-capability model
・ Object-centered high-level reference ontology
・ Object-class detection
・ Object-code Buffer Overrun Evaluator


Dictionary Lists
翻訳と辞書 辞書検索 [ 開発暫定版 ]
スポンサード リンク

Object slicing : ウィキペディア英語版
Object slicing

In object-oriented programming, a subclass can extend its superclass by defining additional member variables. If a superclass instance is assigned its value from a subclass instance, member variables defined in the subclass cannot be copied, since the superclass has no place to store them. This is a natural and unavoidable consequence of assignment by value from subclass objects. The term ''object slicing'' is sometimes used to refer to this aspect of assignment by value to a superclass instance.
''Object slicing'' is also used to refer to a more subtle and problematic case in which an object assignment by value appears to be to a superclass instance but is actually to a subclass instance. From the perspective of object memory layout, the member variables of the source instance can be thought of as having been "sliced off", ''leaving the corresponding member variables in the destination instance unchanged''. It is this ''partial assignment'' (arguably a more apt term) that often surprises programmers and leads to unintended consequences.
Unexpected object slicing can happen in languages such as C++ in which assignment by value is not polymorphic. It is not possible in the D programming language, which allows object inheritance only through reference types.
==Example in C++==

struct A
;
struct B : public A
;
B &getB()
int main()


抄文引用元・出典: フリー百科事典『 ウィキペディア(Wikipedia)
ウィキペディアで「Object slicing」の詳細全文を読む



スポンサード リンク
翻訳と辞書 : 翻訳のためのインターネットリソース

Copyright(C) kotoba.ne.jp 1997-2016. All Rights Reserved.